<link rel="stylesheet" type="text/css" href="<%= resources['css-src'] %>">
<script>
  var isIpv4 = function(domain){
    var regex = /^(\d{1,3}\.){3}(\d{1,3})$/g;
    return regex.test(domain);
  }

  var isIpv6 = function(domain){
    var regex = /^([\dA-F]{4}:){7}([\dA-F]{4})$/g;
    return regex.test(domain);
  }

  var topDomain = function(){
    var domain = location.hostname;
    if(isIpv4(domain)||isIpv6(domain)){
      return domain;
    }
    var arr = domain.split('.');
    if(arr.length >2) {
      return arr.slice(-2).join('.')
    }
    return domain;
  }
  document.domain=topDomain();
  //全局应用变量! 使用const以常量方式定义
  const $CONST_PROJECT = <%- JSON.stringify(project) %>;
  const $CONST_RIGHT = <%- JSON.stringify(right) %>;
  const CONST_HOST = <%- JSON.stringify(host) %>;
  for(var k in CONST_HOST){
    if(CONST_HOST.hasOwnProperty(k)){
      var v = CONST_HOST[k];
      v = v.replace(/\$\{domain\}/g,document.domain);
      CONST_HOST[k] = v;
    }
  }
  const $CONST_HOST = CONST_HOST;
</script>